fix: handle activateProviderProfile errors gracefully during mode switch#12099
Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
Draft
fix: handle activateProviderProfile errors gracefully during mode switch#12099roomote-v0[bot] wants to merge 1 commit intomainfrom
roomote-v0[bot] wants to merge 1 commit intomainfrom
Conversation
When switching modes, if activateProviderProfile fails (e.g. due to corrupted profile data or proxy provider configuration issues), the error would propagate up and leave the mode in an inconsistent state - the mode was already updated in memory and global state, but the API configuration was not switched. This wraps the activateProviderProfile call in handleModeSwitch with a try-catch so the mode switch completes gracefully, falling back to the current API configuration. The error is logged for diagnostics. Closes #12098
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related GitHub Issue
Closes: #12098
Description
This PR attempts to address Issue #12098, where a user reported issues when switching modes (code to architect) with a proxy-based provider (agentrouter).
Root cause: In
handleModeSwitch, ifactivateProviderProfilefails during a mode switch, the error propagates up unhandled. At that point the mode has already been updated in both memory (task._taskMode) and global state, but the API configuration has not been switched to the new mode's profile. This leaves the system in an inconsistent state where the UI shows the new mode but the API handler still uses the old configuration.Fix: Wrap the
activateProviderProfilecall inhandleModeSwitchwith a try-catch. If profile activation fails (e.g. due to corrupted profile data, proxy provider configuration issues, or network errors), the mode switch completes gracefully and the task continues with the current API configuration. The error is logged for diagnostics.Test Procedure
activateProviderProfileto throw an error and verifies:Pre-Submission Checklist
Documentation Updates
Additional Notes
The user's original connection error was resolved by using a new API key. The mode-switching issue they reported was vague ("some other issue while changing mode from code to architect"), but this fix addresses the most likely root cause: unhandled errors during provider profile activation when switching modes. Feedback and guidance are welcome.
Interactively review PR in Roo Code Cloud